package org.example.controller;

import com.qidian.common.pojo.MESResult;
import com.qidian.mes.pojo.TestIndex;
import com.qidian.mes.pojo.TestTemplate;
import org.example.service.TestIndexService;
import org.example.service.TestTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 严伟伦
 * @Company 无
 * @Description
 * @Date: 2024/10/18 14:07
 */
@RestController
@RequestMapping("/testtemplate")
@CrossOrigin
public class TestTemplateController {
    @Autowired
    private TestTemplateService testTemplateService;

    @GetMapping("/list")
    public MESResult list(TestTemplate testTemplate, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){
        return testTemplateService.selectByPage(testTemplate,page,limit);
    }

    @PostMapping("/add")
    public MESResult addTestTemplate(@RequestBody TestTemplate testTemplate){
        System.out.println("111111111111111111111111111111111" + testTemplate);
        return testTemplateService.addTestTemplate(testTemplate);
    }


    @PutMapping("/delete")
    public MESResult deleteTestTemplateById(@RequestParam("templateId") int templateId){

        return testTemplateService.deleteTestTemplateById(templateId);
    }

    @GetMapping("/selectTestTemplateById")
    public MESResult selectTestTemplateById(@RequestParam("templateId") int templateId){

        return testTemplateService.selectTestTemplateById(templateId);
    }

    @PutMapping("/update")
    public MESResult updateTestTemplate(@RequestBody TestTemplate testTemplate){

        return testTemplateService.updateTestTemplate(testTemplate);
    }


}
